package com.zb.mobile.network.controller;

import com.zb.entity.AccounLoginInfo;
import com.zb.result.PageUtil;
import com.zb.result.Result;
import com.zb.service.ZjNetworkEmpBandService;
import com.zb.utils.TokenNetworkUtil;
import com.zb.vo.NetworkEmpBandVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @Author WEN
 * @Date 2024/5/24 0024
 **/
@Api(tags = "服务人员银行卡类接口")
@RestController
@RequestMapping("/mobile/network/emp/band")
public class NetworkEmpMobileBandController {

    @Resource
    private ZjNetworkEmpBandService networkEmpBandService;

    @ApiOperation("保存添加银行卡号")
    @PostMapping("/save")
    public Result save(HttpServletRequest request, @RequestBody @Valid NetworkEmpBandVo empBandVo) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        networkEmpBandService.save(loginInfo, empBandVo);
        return Result.success();
    }

    @ApiOperation("获取银行卡列表")
    @PostMapping("/getBandList")
    public Result getBandList(HttpServletRequest request, @RequestBody PageUtil pageUtil) {
        AccounLoginInfo loginInfo = TokenNetworkUtil.getAccountLoginInfo(request);
        return Result.success().data(networkEmpBandService.getBandList(loginInfo, pageUtil));
    }

    @ApiOperation("获取银行卡详情")
    @GetMapping("/getBandDetail/{id}")
    public Result getBandDetail(@PathVariable @ApiParam(value = "银行卡ID", required = true) Long id) {
        return Result.success().data(PageUtil.row(networkEmpBandService.getBandDetail(id)));
    }

    @ApiOperation("解绑银行卡")
    @PostMapping("/unBindingBand/{id}")
    public Result unBindingBand(@PathVariable @ApiParam(value = "银行卡ID", required = true) Long id) {
        networkEmpBandService.removeById(id);
        return Result.success("解绑成功");
    }
}
